﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ERP_RORZE_TOOL.Tool.BCThoigianlamviecthang
{
    public class ReportConstants
    {
        public const string FormName = "MONTHLY WORKING TIME REPORT";
        public class ReportName
        {
            public const string CheckThoiGian = "Check Thoigian";
            public const string WorkingTime = "Working Time";
            public const string Data = "Data";
            public const string Data2 = "Data2";
            public const string WTSTOGA = "WTSTOGA";
            public const string Baocao = "Baocao";
            public const string HangMuaNgoaiF2Gt = "Hàng mua ngoài F2 GT";
            public const string SsMaCvCacBoPhan = "So sánh mã công việc các bộ phận";
            public const string SsMaCvXuong = "So sánh mã công việc Xưởng";
            public const string TgTongHop = "TG Tổng hợp";
            public const string TgMcVktraMa = "TG MCV Kiểm tra mã";
            public const string TGMCVXuong = "TG MCV Xưởng";
            public const string TGTonghopkiemtra = "TG Tổng hợp kiểm tra";
            public const string TGChitietKiemtra = "TG Chi tiết kiểm tra";

            public const string TimeCard = "TimeCard";
            public const string StaffLisst = "Staff List";

        }

        public class ReportId
        {
            public const int CheckThoiGian = 1;
            public const int WorkingTime = 2;
            public const int Data = 3;
            public const int Data2 = 4;
            public const int WTSTOGA = 5;
            public const int Baocao = 6;
            public const int HangMuaNgoaiF2Gt = 7;
            public const int SsMaCvCacBoPhan = 8;
            public const int SsMaCvXuong = 9;
            public const int TgTongHop = 10;
            public const int TgMcVktraMa = 11;
            public const int TGMCVXuong = 12;
            public const int TGTonghopkiemtra = 13;
            public const int TGChitietKiemtra = 14;

            public const int Timecard = 15;
            public const int StaffList = 16;
        }

        public class StoredProcedure
        {
            public const string CheckThoiGian = "Sp_242_3_Rpt_CheckThoigian";
            public const string WorkingTime = "Sp_242_3_Rpt_WorkingtimeChinhthuc1";
            public const string Data = "Sp_242_3_Rpt_Data";
            public const string Data2 = "Sp_242_3_Rpt_Data2Query";
            public const string WTSTOGA = "Sp_242_3_Rpt_WTSTOGAT4Query";
            public const string Baocao = "Sp_242_3_Rpt_QReport1Query";
            public const string HangMuaNgoaiF2Gt = "Sp_242_3_Rpt_QMuangoai_F2";
            public const string SsMaCvCacBoPhan = "Sp_242_3_Rpt_QSSMaCV";
            public const string SsMaCvXuong = "Sp_242_3_Rpt_QSSMCV_Xuong1";
            public const string TgTongHop = "Sp_242_3_Rpt_QTGGianTiepTonghop";
            public const string TgMcVktraMa = "Sp_242_3_Rpt_QTGGianTiepMa_Ktra1";
            public const string TGMCVXuong = "Sp_242_3_Rpt_QTGGianTiepXuong1";
            public const string TGTonghopkiemtra = "Sp_242_3_Rpt_QSSMCV_Kiemtra_Crosstab";
            public const string TGChitietKiemtra = "Sp_242_3_Rpt_QSSMCV_KiemtraQuery";

        }

        public class Table
        {
            public const string Timecard = "TimeCard";
            public const string StaffList = "StaffList";

        }

        public class Message
        {
            public const string DateIsNotNull = "Please enter the date in the format \"MM/DD/YYYY\".";
            public const string DateIsWrongFormat = "Please enter the date in the format \"YYYY-MM\".";

            public const string AddSuccess = "Data added Successfully";
            public const string AddSuccessAndQuestion = "Data added succesfully. Do you want to continue adding data?";
            public const string UpdateSuccessAndQuestion = "Data updated succesfully. Do you want to update again?";
            public const string AddFailed = "An error occurred while inserting the record to database. Please try again.";
            public const string UpdateSuccess = "Update Successfully";
            public const string UpdateFailed = "An error occurred while updating the record to database. Please try again.";
            public const string DeleteQuestion = "Do you want to permanently delete this item(s)?";
            public const string DeleteFailed = "Error occurred when deleting data. Please try again.";
            public const string FormAlreadyOpened = "This form is already opened.";
            public const string TableIsNull = "No data to edit/delete.";
            public const string QuestionUpdateTool = "Are you sure you want to replace the data from {0} into {1}?";
            public const string NoDataToExport = "No data to export.";
            public const string ErrorToExport = "cannot export.";
            public const string ImportSuccessfully = "Import {0} row(s) successfully. Do you want to refresh data now?";
            public const string ImportSuccessfullyLog = "Table [333_Import]: Import {0} row(s) successfully.";
            public const string ImportFailedLog = "Table [333_Import]: Import data failed.\n Message: {0}";
            public const string QuestionOpenFileExport = "Do you want to open the file?";
        }


        public class Item
        {
            public string Name;
            public int Value;
            public Item(string name, int value = -1)
            {
                Name = name; Value = value;
            }
            public override string ToString()
            {
                // Generates the text shown in the combo box
                return Name;
            }
        }

        public static void AdjustWidthComboBox(object sender, EventArgs e)
        {
            System.Windows.Forms.ComboBox senderComboBox = (System.Windows.Forms.ComboBox)sender;
            int width = senderComboBox.DropDownWidth;
            Graphics g = senderComboBox.CreateGraphics();
            Font font = senderComboBox.Font;
            int vertScrollBarWidth =
                (senderComboBox.Items.Count > senderComboBox.MaxDropDownItems)
                ? SystemInformation.VerticalScrollBarWidth : 0;

            int newWidth;
            foreach (object item in ((System.Windows.Forms.ComboBox)sender).Items)
            {
                newWidth = (int)g.MeasureString(item.ToString(), font).Width
                    + vertScrollBarWidth;
                if (width < newWidth)
                {
                    width = newWidth;
                }
            }
            senderComboBox.DropDownWidth = width;
        }
    }
}
